{% embed 'Embed/table_embed.html.twig' %}
    {% import 'Import/app_import.html.twig' as appImport %}

    {% set columns = {'name': true, 'indices': true, 'match_field': true, 'enrich_fields': true, 'query': true} %}

    {% block thead %}
        <tr>
            {% for column, display in columns %}
                {% if true == display %}
                    {% if 'name' == column %}
                        <th>
                            {{ 'name'|trans }}{{ appImport.badge({'title': 'sort_asc'|trans, 'context': 'secondary'}) }}
                        </th>
                    {% endif %}

                    {% if 'indices' == column %}
                        <th>
                            {{ 'indices'|trans }}
                        </th>
                    {% endif %}

                    {% if 'match_field' == column %}
                        <th>
                            {{ 'match_field'|trans }}
                        </th>
                    {% endif %}

                    {% if 'enrich_fields' == column %}
                        <th>
                            {{ 'enrich_fields'|trans }}
                        </th>
                    {% endif %}

                    {% if 'query' == column %}
                        <th>
                            {{ 'query'|trans }}
                        </th>
                    {% endif %}
                {% endif %}
            {% endfor %}
        </tr>
    {% endblock %}

    {% block tbody %}
        {% for row in policies.rows %}
            <tr>
                {% for column, display in columns %}
                    {% if true == display %}
                        {% if 'name' == column %}
                            <td>
                                <a class="{{ theme_link_primary }}" href="{{ path('enrich_read', {'name': row.name}) }}">{{ row.name }}</a>
                            </td>
                        {% endif %}

                        {% if 'indices' == column %}
                            <td>
                                {{ row.indices|join(', ') }}
                            </td>
                        {% endif %}

                        {% if 'match_field' == column %}
                            <td>
                                {{ row.matchField }}
                            </td>
                        {% endif %}

                        {% if 'enrich_fields' == column %}
                            <td>
                                {{ row.enrichFields|join(', ') }}
                            </td>
                        {% endif %}

                        {% if 'query' == column %}
                            <td>
                                {{ row.query }}
                            </td>
                        {% endif %}
                    {% endif %}
                {% endfor %}
            </tr>
        {% endfor %}
    {% endblock %}
{% endembed %}
